#include <REGX52.H>
#include "Timer0.h"
#include "Key.h"
#include <INTRINS.H>

unsigned char KeyNum,LEDMode;

void main()
{
	Timer0Init();
	P2 = 0xFE;
	while (1)
	{
		KeyNum = Key();
		if (KeyNum)
		{
			if (1 == KeyNum)
			{
				LEDMode++;
				if(LEDMode >= 2)LEDMode = 0;
			}
		}
	}
}

void Timer0_Rountine() interrupt 1
{	
	static unsigned int T0Count = 0;
	TL0 = 0x66;		//设置定时初值
	TH0 = 0xFC;		//设置定时初值
	T0Count++;	
	if (T0Count >= 500)
	{
		T0Count = 0;
		
		if (0 == LEDMode)
			P2 = _crol_(P2,1);
		else
			P2 = _cror_(P2,1);
	}
}









































